/**
 * 
 */
package lex.profile.ui.outline;

import java.awt.Color;
import java.lang.reflect.Modifier;

import javax.swing.Icon;

import lex.profile.utils.IconCache;

import org.netbeans.swing.outline.RenderDataProvider;

import com.vladium.utils.IObjectProfileNode;

public class ObjectProfileNodeRenderer implements RenderDataProvider
{
	private static final Icon PRIVATE = IconCache.getIcon( IconCache.PRIVATE );
	private static final Icon PACKAGE = IconCache.getIcon( IconCache.PACKAGE );
	private static final Icon PROTECT = IconCache.getIcon( IconCache.PROTECT );
	private static final Icon PUBLIC = IconCache.getIcon( IconCache.PUBLIC );

	@Override
	public String getDisplayName( Object o )
	{
		return ((IObjectProfileNode) o).name();
	}

	@Override
	public Color getBackground( Object o )
	{
		return null;
	}

	@Override
	public Color getForeground( Object o )
	{
		return null;
	}

	@Override
	public Icon getIcon( Object o )
	{
		int mod = ((IObjectProfileNode) o).getModifiers();
		if( Modifier.isPrivate( mod )) 
			return PRIVATE;
		else if( Modifier.isProtected( mod ))
			return PROTECT;
		else if( Modifier.isPublic( mod ) )
			return PUBLIC;
		else if( 0 == mod )
			return PACKAGE;
		return null;
	}

	@Override
	public String getTooltipText( Object o )
	{
		return null;
	}

	@Override
	public boolean isHtmlDisplayName( Object o )
	{
		return false;
	}
}
